var report = new Vue({
	el: '#report',
	data: {
		plantpie:[],
		breedpie:[],
		plantline:null,
		breedline:null,
		dxpie:[],
		dxline:null,
		fammerpie:[]
	},
	watch: {
	
	},
	mounted: function() {
	this.getData()
	},
	methods: {
		getData:function(){
			var _this = this
			axios({
				url: sever + '/infopie',
				method: 'POST',
				// 请求体重发送的数据
				params: {
	
				},
				timeout: 50000,
				// 设置请求头
				headers: {
					'Content-Type': 'application/x-www-form-urlencoded'
				}
			}).then(function(res){ 
				_this.plantpie = res.data.plantpie;
				_this.breedpie = res.data.breedpie;
				_this.plantline = res.data.plantline;
				_this.breedline = res.data.breedline;
				_this.dxline = res.data.dxline;
				_this.dxpie = res.data.dxpie;
				_this.fammerpie = res.data.fammerpie;
				_this.drawPie();
				_this.drawLine();
			})
		},
		drawLine:function(){
			    var _this = this
				var getOption = function() {
				var chartOption = {
				
					grid: {
						x: 35,
						x2: 10,
						y: 30,
						y2: 25
					},
					toolbox: {
						show: false,
						feature: {
							mark: {
								show: true
							},
							dataView: {
								show: true,
								readOnly: false
							},
							magicType: {
								show: true,
								type: ['line', 'bar']
							},
							restore: {
								show: true
							},
							saveAsImage: {
								show: true
							}
						}
					},
					calculable: false,
					xAxis: [{
						type: 'category',
						data: _this.plantline.city
					}],
					yAxis: [{
						type: 'value',
						splitArea: {
							show: true
						}
					}],
					series: [{
						name: '种植',
						type: "bar",
						data: _this.plantline.data
					}]
				};
				return chartOption;
			};
			
			var getOption2 = function() {
				var chartOption = {
				
					grid: {
						x: 35,
						x2: 10,
						y: 30,
						y2: 25
					},
					toolbox: {
						show: false,
						feature: {
							mark: {
								show: true
							},
							dataView: {
								show: true,
								readOnly: false
							},
							magicType: {
								show: true,
								type: ['line', 'bar']
							},
							restore: {
								show: true
							},
							saveAsImage: {
								show: true
							}
						}
					},
					calculable: false,
					xAxis: [{
						type: 'category',
						data: _this.breedline.city
					}],
					yAxis: [{
						type: 'value',
						splitArea: {
							show: true
						}
					}],
					series: [{
						name: '养殖',
						type: "bar",
						data: _this.breedline.data
					}]
				};
				return chartOption;
			};
			
				var getOption3 = function() {
				var chartOption = {
				
					grid: {
						x: 35,
						x2: 10,
						y: 30,
						y2: 25
					},
					toolbox: {
						show: false,
						feature: {
							mark: {
								show: true
							},
							dataView: {
								show: true,
								readOnly: false
							},
							magicType: {
								show: true,
								type: ['line', 'bar']
							},
							restore: {
								show: true
							},
							saveAsImage: {
								show: true
							}
						}
					},
					calculable: false,
					xAxis: [{
						type: 'category',
						data: _this.dxline.city
					}],
					yAxis: [{
						type: 'value',
						splitArea: {
							show: true
						}
					}],
					series: [{
						name: '订销情况',
						type: "bar",
						data: _this.dxline.data
					}]
				};
				return chartOption;
			};
			
				var byId = function(id) {
				return document.getElementById(id);
			};
			
			var areaPlantLine = echarts.init(byId('areaPlantLine'));
			areaPlantLine.setOption(getOption());
			
				var areaBreedLine = echarts.init(byId('areaBreedLine'));
			areaBreedLine.setOption(getOption2());
					var areaDxLine = echarts.init(byId('areaDxLine'));
			areaDxLine.setOption(getOption3());

			
		},
		drawPie:function(){
			var _this = this
			var getOption = function(chartType) {
				var chartOption = {
					calculable: false,
					series: [{
						type: 'pie',
						data: _this.plantpie
					}]
				};
				return chartOption;
			};
			var getOption2 = function(chartType) {
				var chartOption = {
					calculable: false,
					series: [{
						type: 'pie',
						data: _this.breedpie
					}]
				};
				return chartOption;
			};
				var getOption3 = function(chartType) {
				var chartOption = {
					calculable: false,
					series: [{
						type: 'pie',
						data: _this.dxpie
					}]
				};
				return chartOption;
			};
				var getOption4 = function(chartType) {
				var chartOption = {
					calculable: false,
					series: [{
						type: 'pie',
						data: _this.fammerpie
					}]
				};
				return chartOption;
			};
						var byId = function(id) {
				return document.getElementById(id);
			};
			
			var plantPieChart = echarts.init(byId('plantPieChart'));
			plantPieChart.setOption(getOption());
			
			var breedBarChart = echarts.init(byId('breedBarChart'));
			breedBarChart.setOption(getOption2());
			
			var dxBarChart = echarts.init(byId('dxPieChart'));
			dxBarChart.setOption(getOption3());
			
				var farmerLineChart = echarts.init(byId('farmerLineChart'));
			farmerLineChart.setOption(getOption4());
			
			
			
			
		}
	},
});